const useCommodityStore = defineStore(
  // 唯一ID
  'NewCacheData', () => {
    const formData = new Map()

    // 初始化表单数据
    function initObjectFormData(key: any, defaultValue = {}) {
      formData.set(key, defaultValue)
      // console.log(123)
    }

    // 获取表单数据
    function getFormData(key: any) {
      return formData.get(key)
    }

    // 记住表单数据
    function rememberFormData(key: any, data: any) {
      formData.set(key, data)
    }

    // 清空表单数据
    function emptyFormData(key: any) {
      const defaultValue = formData.get(key)
      if (Array.isArray(defaultValue)) {
        formData.set(key, [])
      }
      else {
        formData.set(key, {})
      }
    }

    // 初始化所有表单
    initObjectFormData('fukaZhuliFrom', {
      fukaActId: '',
      ticketId: '',
      usedUrl: '',
      change: 0,
      stock: 0,
      used: 0,
      flag: 0,
      picUrl: '',
      prizeListBg: '',
      prizeCoverpic: '',
    })
    // 商品发布
    initObjectFormData('commodityFrom', {
      actJson: [{
        actType: 0,
        actId: '',
        vipGiftTicketId: '',
        focaType: 1,
      }],
      productName: '',
      flag: 1,
      productNums: undefined,
      marketPrice: '',
      salePrice: '',
      baseSaleCount: '',
      outProductCode: '',
      outProductGuiGe: '',
      weight: undefined,
      isActive: true,
      cdnqrCodeBGPicUrl: '',
      activeTime: '',
      isDeliver: 1,
      cdnProductPhotoPic: '',
      coverImages: [],
      introduceImages: [],
      limitEveryBuyCount: 0,
      limitOpenIdBuyCount: 0,
      relateTicketBuyLimit: 0,
      displayInShop: 1,
      buyedFaTicketId: 0,
      isRefuned: 0,
      isUpdateAddress: 1,
      videoUrl: '',
      CoverVideoUrl: '',
      coverAutoPlay: 1,
      orderSaleType: 0,
      keywords: '',
      kuaiDiGongSi: '',
      brandId: 0,
      picMoudle: [],
      seriesList: [],
      stepList: [],
      subjectList: [],
    })
    // 新增卡券
    initObjectFormData('voucherFrom', {
      name: '',
      price: undefined,
      type: undefined,
      count: undefined,
      productCode: '',
      flag: 0,
      picUrl: '',
      intro: '',
      endTime: '',
      relateProduct: 0,
      relateProductBanner: '',
      type3PriceArray: [],
      syncMethod: 1,
    })
    // 新增落地页
    initObjectFormData('videoFrom', {
      landingName: '',
      landingType: 0,
      landingLine: 0,
      customerServiceSwitch: true,
      customerServicePic: '',
      customerServiceLink: '',
      buyNocouponPic: '',
      buyCouponPic: '',
      buyNovipPic: '',
      buyVipPic: '',
      landingBg: [], // 背景图，多
      outProductId: 0,
      outCouponId: 0,
      payBeforePic: '',
      payBeforeSwitch: true,
      payAfterPic: '',
      payAfterSwitch: true,
      scrollingSwitch: 1,
      payLayerSwitch: 0,
      payLayerPic: [],
      landingStatus: false,
      landingId: 0,
    })
    // 企微消息
    initObjectFormData('enterpriseWeChatFrom', {
      title: '',
      pagepath: '',
      msgtype: 78,
      desp: '',
      weappIconUrl: '',
      cardPicUrl: '',
    })
    // 消息组
    initObjectFormData('messageFrom', {
      groupName: '',
      type: undefined,
      relateConfigArray: [],
    })
    // 人员管理
    initObjectFormData('peopleFrom', {
      account: '',
      password: '',
      mobile: 0,
      role: 2,
      enable: true,
      description: '',
      id: 0,
    })
    // 会员攻略图标
    initObjectFormData('vipLconFrom', {
      title: '',
      linkUrl: '',
      sort: '',
      iconPic: '',
      iconType: '',
      isJump: false,
    })
    // 广告屏
    initObjectFormData('screenFrom', {
      name: '',
      machineCode: '',
      vid: 0,
      drawId: 0,
      storeId: 0,
      bannerJson: [],
      qvQrCodePic: '',
      drawBoxId: '',
    })
    // 音乐页面配置
    initObjectFormData('musicFrom', {
      musicUrl: '',
      soundOnIcon: '',
      soundTurnOffIcon: '',
      backgroundPic: '',
      description: '',
      enable: true,
    })
    // 图标管理
    initObjectFormData('iconFrom', {
      display: 0,
      iconClass: '',
      iconPic: '',
      turnLink: '',
      positionTop: 0,
      iconType: 1,
      positionRight: 0,
      layerPic: '',
    })
    // 核销
    initObjectFormData('hexiaoFrom', {
      openId: '',
      mobile: '',
      enable: true,
      jingDianShopName: '',
      id: 0,
    })
    // 抽奖活动奖品
    initObjectFormData('drawactprizeFrom', {
      prizeName: '',
      prizePic: '',
      prizePicScreen: '',
      prizeType: 1,
      productId: 0,
      change: 0,
      prizeNums: 0,
      usedNums: 0,
      flag: -1,
      ticketId: 0,
      sort: 0,
      drawId: 0,
    })
    // 订阅消息模板
    initObjectFormData('subscribermsgtempleFrom', {
      wxTemplateId: '',
      wxTemplateTitle: '',
      templateIcon: '',
      linkUrl: '',
      content1: '',
      content2: '',
      content3: '',
      content4: '',
      templateKeywords: [],
      enable: true,
      templateType: 4,
    })
    // 抽奖活动
    initObjectFormData('drawactFrom', {
      drawBg: '',
      wheelBg: '',
      drawPrebg: '',
      newUserNums: 0,
      bgColor: '',
      btnBg: '',
      btnBgColor: '',
      ruleIcon: '',
      rulePic: '',
      myprizeBg: '',
      myprizeIcon: '',
      myprizeTicketbg: '',
      myprizeTicketbg2: '',
      moreIcon: '',
      moreLink: '',
      productJson: [],
      getPrizeLayer: '',
      getPrizeTypeColor: '',
      getPrizeNameColor: '',
      getPrizeBtnColor: '',
      getPrizeBgbtnColor: '',
      sharePic: '',
      shareTxt: '',
      actStatus: 0,
      beginTime: '',
      endTime: '',
      drawId: '',
      descriptionTxt: '',
      descriptionPic: '',
      drawActTasks: [],
    })
    // 客户端账号
    initObjectFormData('drawactAdminAccountFrom', {
      username: '',
      pwd: '',
      mobile: '',
      roleId: 1,
      realname: '',
      nickname: '',
      headimgurl: '',
      expiredTime: '',
      accountState: 1,
      storeId: '',
      openId: '',
      id: 0,
    })
    // 客户端账号
    initObjectFormData('drawactAccountLabelFrom', {
      labelName: '',
      labelType: 1,
      adminId: 0,
      id: 0,
    })
    // 送面膜
    initObjectFormData('givefacialmaskactFrom', {
      title: '',
      bgColor: '',
      bgImg: '',
      getTicketBtn: '',
      shareBtn: '',
      ticketBaoIcon: '',
      ticketId: '',
      ticketsArray: [],
      processBgColor: '',
      processColor: '',
      taskJson: [],
      getTaskBtn: '',
      noFinishBtn: '',
      finishBtn: '',
      shareTxt: '',
      shareImg: '',
      bottomLogo: '',
      getListIcon: '',
      nogetListIcon: '',
      actStatus: 0,
      qvPic: '',
      ticketBaoBg: '',
      descriptionTxt: '',
      descriptionPic: '',
    })
    // 运费模板配置
    initObjectFormData('postageFrom', {
      province: '',
      city: '',
      baseKg: 0,
      baseFee: 0,
      stepKg: 0,
      stepFee: 0,
      flag: 0,
    })
    // 会员级别
    initObjectFormData('memberlevelsFrom', {
      vipLevel: 0,
      vipName: '',
      vipCard: '',
      vipLogo: '',
      vipWidget: '',
      vipIntegralLimit: 0,
      id: 0,
    })
    // 积分商城商品
    initObjectFormData('memberproductFrom', {
      productId: 0,
      payType: 1,
      saleScore: 0,
      secTime: '',
      secEndTime: '',
      secLabels: '',
      id: '',
    })
    // 活动管理--会员日
    initObjectFormData('memberholidayFrom', {
      name: '',
      banner: '',
      openType: 0,
      openDate: 0,
      productIdsSec: '',
      productIdsNom: '',
      startDate: '',
      endDate: '',
      actModule: { // 提供默认结构
        act_type: 1, // 默认值需与el-option的value匹配
        act_id: 0,
        banner: '',
        jump_url: '',
      },
    })
    // 零元使用
    initObjectFormData('freetrialFrom', {
      title: '',
      proImg: '',
      productid: 0,
      minVipLevel: 0,
      startTime: '',
      lotteryTime: '',
      qrcodeBgimg: '',
      shareTxt: '',
      shareImg: '',
      limitCon: 0,
      subscribeCon: 0,
      applyCon: 0,
      enable: true,
      sort: 0,
      buyUrl: '',
    })
    // 零元试用
    initObjectFormData('voucherFrom', {
      title: '',
      proImg: '',
      productid: 0,
      minVipLevel: 0,
      startTime: '',
      lotteryTime: '',
      qrcodeBgimg: '',
      shareTxt: '',
      shareImg: '',
      limitCon: 0,
      subscribeCon: 0,
      applyCon: 0,
      enable: true,
      sort: 0,
      buyUrl: '',
    })
    // 生日礼
    initObjectFormData('birthdayFrom', {
      bannerPics: [],
      giftJson: [
        {
          vip_level: 0,
          ticketId: 0,
          score: 0,
        },
      ],
      productIds: [
      ],
      qvPic: '',
      shareTxt: '',
      sharePic: '',
      flag: 0,
    })
    // 评测记录
    initObjectFormData('freetrialEvaluationFrom', {
      trialApplyId: 0,
      trialProductId: 0,
      userId: 0,
      openId: '',
      nickName: '',
      avatar: '',
      scoreOverall: 0,
      scoreItem1: 0,
      scoreItem2: 0,
      scoreItem3: 0,
      scoreItem4: 0,
      scoreItem5: 0,
      contents: '',
      pictures: [],
      viewCon: 0,
      praiseCon: 0,
      addTime: '',
      auditStatus: 0,
    })
    // 品牌管理
    initObjectFormData('brandFrom', {
      brandName: '',
      logo: '',
      logoActive: '',
      topImg: '',
      shareTxt: '',
      shareImg: '',
      sort: 0,
      enable: true,
      desp: '',
    })
    // 系列管理
    initObjectFormData('seriesFrom', {
      brandId: 0,
      seriesName: '',
      banner: '',
      shareTxt: '',
      shareImg: '',
      sort: 0,
      enable: true,
      desp: '',
      introImgArray: [],
    })
    // 步骤管理
    initObjectFormData('stepFrom', {
      brandId: 0,
      stepName: '',
      stepNum: 0,
      stepImg: '',
      shareTxt: '',
      shareImg: '',
      enable: true,
      desp: '',
    })
    // 搜索关键词
    initObjectFormData('hotwordsFrom', {
      keyword: '',
      jumpType: 1,
      jumpUrl: '',
      sort: 0,
      enable: true,
      desp: '',
    })
    // 店铺管理
    initObjectFormData('shopFrom', {
      shopName: '',
      shopPic: '',
      shopAddress: '',
      phone: '',
      shopStatus: 1,
      desp: '',
    })
    // 专题管理
    initObjectFormData('subjectFrom', {
      subjectName: '',
      banners: [],
      shareTxt: '',
      shareImg: '',
      sort: 0,
      enable: true,
      desp: '',
    })
    // 门店管理
    initObjectFormData('storeFrom', {
      storeName: '',
      storePic: '',
      storeAddress: '',
      phone: '',
      storeStatus: 1,
    })
    // 幸运盲盒活动
    initObjectFormData('drawboxactFrom', {
      bgPic: '',
      bgColor: '',
      wheelBgColor: '',
      tipTxt1: '',
      payBtnPic: '',
      tipTxt2: '',
      startBtnPic: '',
      tipTxt3: '',
      getBtnPic: '',
      awardbgPic: '',
      selectAwardbgPic: '',
      selectNums: 0,
      qrcodePic: '',
      drawPic: '',
      noDrawPic: '',
      layerAwardbgPic: '',
      noBtnPic: '',
      yesBtnPic: '',
      drawStatus: 0,
      sharePic: '',
      shareTxt: '',
      myBoxBgPic: '',
      myBoxBtnPic: '',
      myAwardBgPic: '',
      ruleBgpic: '',
      ruleBtnPic: '',
    })
    // 幸运盲盒档位
    initObjectFormData('drawboxactLevelFrom', {
      drawBoxId: 0,
      levelPic: '',
      selectLevelPic: '',
      levelPrice: 0,
      sort: 0,
      desp: '幸运盲盒',
      flag: 1,
      prizes: [
        {
          drawLevelId: 0,
          prizePic: '',
          change: 0,
          flag: 1,
          sort: 0,
          ticketId: 0,
          stock: 0,
          used: 0,
          desp: '',
        },
      ],
    })
    // 幸运盲盒奖品
    initObjectFormData('drawboxactPrizeFrom', {
      drawLevelId: 0,
      prizePic: '',
      change: 0,
      showChange: 0,
      flag: 0,
      sort: 0,
      ticketId: 0,
      stock: 0,
      used: 0,
      desp: '',
    })
    // 落地页活动配置
    initObjectFormData('collectionFrom', {
      bannerPic: '',
      bottomPic: '',
      sharePic: '',
      shareTxt: '',
      getBtnPic: '',
      usedBtnPic: '',
      actStatus: 0,
    })
    // 福卡活动
    initObjectFormData('fukaFrom', {
      startTime: '',
      endTime: '',
      flag: 0,
      fukaChange: 0,
      bgPic: '',
      nofukaPic: '',
      sharePic: '',
      shareTxt: '',
      shareZhuliTxt: '',
      shareSongTxt: '',
      zhuliBgpic: '',
      rulePic: '',
      lingfukaBgpic: '',
      drawBgpic: '',
      drawBtn: '',
      shareBtnpic: '',
      fudaiUrl: '',
      myPrizeBg: '',
      descriptionTxt: '',
      descriptionPic: '',
      qvcodePic: '',
      drawStartTime: '',
      ruleBtn: '',
      myprizeBtn: '',
      cardList: [
        {
          fukaName: '',
          tagId: 1,
          fukaChange: 0,
          fukaPic1: '',
          fukaPic2: '',
          fukaPic3: '',
        },
        {
          fukaName: '',
          tagId: 2,
          fukaChange: 0,
          fukaPic1: '',
          fukaPic2: '',
          fukaPic3: '',
        },
        {
          fukaName: '',
          tagId: 3,
          fukaChange: 0,
          fukaPic1: '',
          fukaPic2: '',
          fukaPic3: '',
        },
        {
          fukaName: '',
          tagId: 4,
          fukaChange: 0,
          fukaPic1: '',
          fukaPic2: '',
          fukaPic3: '',
        },
        {
          fukaName: '',
          tagId: 5,
          fukaChange: 0,
          fukaPic1: '',
          fukaPic2: '',
          fukaPic3: '',
        },
      ],
      zhuLiTicketList: [
        {
          ticketId: 0,
          usedUrl: '',
          change: 0,
          stock: 0,
          used: 0,
          flag: 0,
          picUrl: '',
          prizeListBg: '',
          prizeCoverpic: '',
        },
      ],
    })
    // 福卡活动关联商品
    initObjectFormData('fukaProductFrom', {
      fukaActId: 0,
      productId: 0,
      productPic: '',
      productUrl: '',
      sort: 0,
      flag: 0,
    })
    // 奖品池
    initObjectFormData('fukaPrizeFrom', {
      fukaActId: 0,
      prizeName: '',
      prizePic: '',
      prizeType: '',
      prizeKindid: '',
      usedUrl: '',
      prizeCoverpic: '',
      change: 0,
      stock: 0,
      used: 0,
      flag: 0,
      sort: 0,
      desp: '',
      prizeListBg: '',
    })
    // 助力券
    initObjectFormData('fukaZhuliFrom', {
      fukaActId: '',
      ticketId: '',
      usedUrl: '',
      change: 0,
      stock: 0,
      used: 0,
      flag: 0,
    })
    // 福卡-任务
    initObjectFormData('fukaTaskFrom', {
      fukaActId: '',
      classId: '',
      taskPic: '',
      taskStatus: -1,
      linkUrl: '',
      sort: 0,
    })
    // 任选-活动
    initObjectFormData('renxuanFrom', {
      title: '',
      banner: '',
      amount: 0,
      nums: 0,
      zengpinTitle: '',
      zengpinPic: '',
      zengpinCode: '',
      shareTxt: '',
      shareImg: '',
      actStatus: 0,
      desp: '',
    })
    // 任选-关联商品
    initObjectFormData('renxuanProductFrom', {
      rxActId: 0,
      productId: 0,
      limitCon: 0,
      sort: 0,
      enable: false,
      desp: '',
    })
    // 团购活动-团长
    initObjectFormData('tuanleaderForm', {
      name: '',
      avatar: '',
      levelPic: '',
      labels: '',
      shareTxt: '',
      shareImg: '',
    })
    // 团购活动-团长
    initObjectFormData('tuanForm', {
      tuanLeaderId: 0,
      tuanTitle: '',
      tuanDesp: '',
      banner: '',
      productId: 0,
      coverPic: [],
      detailPic: '',
      viewCon: 0,
      pubTime: '',
      endTime: '',
      shareTxt: '',
      shareImg: '',
      enable: true,
      vipJson: [],
    })
    // 团购活动-跟团订单
    initObjectFormData('tuanOrderForm', {
      tuanRecId: 0,
      tuanInfoId: 0,
      orderId: 0,
      nickName: '',
      avatar: '',
      productName: '',
      productCon: 0,
      recStatus: 1,
      addTime: '',
    })
    // 团购活动-
    initObjectFormData('tuanEvaluationForm', {
      tuanEvaluationId: 0,
      tuanInfoId: 0,
      tuanLeaderId: 0,
      userId: 0,
      openId: '',
      nickName: '',
      avatar: '',
      contents: '',
      pictures: [],
      auditStatus: 1,
      auditReason: '',
      auditTime: '',
      viewCon: 0,
      praiseCon: 0,
      addTime: '',
    })
    // 签到活动
    initObjectFormData('signintaskForm', {
      taskType: '1',
      pic: '',
      title: '',
      taskDesp: '',
      awardDesp: '',
      awardScore: 0,
      signDays: 1,
      ticketId: 0,
      linkUrl: '',
      qvcodePic: '',
      templateIds: '',
      taskStatus: -1,
      sort: 0,
      enable: 1,
    })
    // 测肤记录-测肤券
    initObjectFormData('skincheckTicketFrom', {
      skinKey: '',
      ticketId: 0,
      ticketDesp: '',
      linkUrl: '',
      status: 0,
    })
    // 测肤记录-连连看绑定券
    initObjectFormData('skincheckLlksentFrom', {
      skinKey: '',
      ticketId: 0,
      ticketDesp: '',
      linkUrl: '',
      status: 0,
    })
    // 测肤记录-连连看绑定券
    initObjectFormData('sysshareconfigFrom', {
      actId: 0,
      shareTxt: '',
      shareImg: '',
    })
    // 广告机兑换码活动
    initObjectFormData('ScreenCodeActFrom', {
      kfIcon: '',
      kfPop: '',
      actJson: [],
      status: 0,
      desp: '',
    })
    // 品牌官-裂变券编辑
    initObjectFormData('brandoffcialTicketFrom', {
      bannerPic: '',
      ruleBtnPic: '',
      rulePic: '',
      ticketId: 0,
      ticketBgpic: '',
      bannerTxtPic: '',
      productIds: '',
      shareBtnPic: '',
      qrcodeBtnPic: '',
      qrcodeBgpic: '',
      status: 0,
      sharePic: '',
      shareTxt: '',
    })
    // 品牌官-人员编辑
    initObjectFormData('brandoffcialAccountFrom', {
      userId: 0,
      roleId: 2,
      realName: '',
      userMobile: '',
      userStatus: 2,
      faceUrl: '',
      desp: '',
    })
    // 品牌官-人员编辑
    initObjectFormData('syncwdtFrom', {
      userId: 0,
      userStatus: 0,
      desp: '',
    })
    // 商品转发素材配置
    initObjectFormData('productshareFrom', {
      productId: '',
      shareType: 1,
      shareSchema: '',
      sharePic: '',
      shareTxt: '',
      desp: '',
    })

    return {
      getFormData,
      rememberFormData,
      emptyFormData,
    }
  },
)
export default useCommodityStore
